#pragma once
/***********************************************************************************************
COPYRIGHT 2011 Mafahir Fairoze

This file is part of Neural++.
(Project Website : http://mafahir.wordpress.com/projects/neuralplusplus)

Neural++ is a free software. You can redistribute it and/or modify it under the terms of
the GNU General Public License as published by the Free Software Foundation, either version 3
of the License, or (at your option) any later version.

Neural++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License <http://www.gnu.org/licenses/> for more details.

***********************************************************************************************/
#include "../Backpropagation/ActivationLayer.h"
#include "../Backpropagation/BackpropagationConnector.h"

using namespace NeuralPlusPlus::Core::Backpropagation;

namespace NeuralPlusPlus
	{
	namespace Core
		{
		namespace Initializers        
			{
			/// <summary>
			/// An <see cref="IInitializer"/> using Nguyen Widrow function.
			/// </summary>
			class NguyenWidrowFunction : public IInitializer
				{
				private: double OutputRange;

						/// <summary>
						/// Creates a new NGuyen Widrow function using the given output range
						/// </summary>
				public: NguyenWidrowFunction(double outputRange =1);

						/// <summary>
						/// Initializes bias values of activation neurons in the activation layer.
						/// </summary>
						/// <param name="activationLayer">
						/// The activation layer to initialize
						/// </param>
						/// <exception cref="ArgumentNullException">
						/// If <c>activationLayer</c> is <c>NULL</c>
						/// </exception>
				public: void Initialize(Layer *activationLayer);

						/// <summary>
						/// Initializes weights of all backpropagation synapses in the backpropagation connector.
						/// </summary>
						/// <param name="connector">
						/// The backpropagation connector to initialize.
						/// </param>
						/// <exception cref="ArgumentNullException">
						/// If <c>connector</c> is <c>NULL</c>
						/// </exception>
				public: void Initialize(Connector *connector);

						/// <summary>
						/// Private helper method to calculate Nguyen-Widrow factor
						/// </summary>
						/// <param name="inputNeuronCount">
						/// Number of input neurons
						/// </param>
						/// <param name="hiddenNeuronCount">
						/// Number of hidden neurons
						/// </param>
						/// <returns>
						/// The Nguyen-Widrow factor
						/// </returns>
				private: double NGuyenWidrowFactor(int inputNeuronCount, int hiddenNeuronCount);
				};
			}
		}
	}